home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / util / rexx / xdmd1.lha / .edrc next >
Text File  |  1994-10-29  |  29KB  |  685 lines

  1. #       XDMD Version 1.00 by Fergus Duniho #
  2.  
  3. # give XDME more CPU-time
  4. taskpri 1
  5.  
  6. #Environment variables
  7. setenv F ()
  8. setenv R ()
  9.  
  10. #Global Variables
  11. set igncase 1
  12. set pparam ()
  13. set Dict `Work:Dict/Dictionary'
  14.  
  15. #Global defaults for variables that get set locally
  16. set mode (Programming)
  17. set fontname topaz.font
  18. set fontsize 8
  19. set cr return
  20. set ftab tab
  21. set btab backtab
  22. set rbrace x-]
  23. set password 0
  24. set method NONE
  25.  
  26. #Macros
  27.  
  28. # $arg1 = $arg2 - $arg3
  29. setmacro minus 3 (set \$arg1 \$arg2 sub \$arg1 \$arg3)
  30.  
  31. # Creates a string of n spaces called $spaces
  32. # usage: spaces n
  33. setmacro spaces 1 (set spaces () \$arg1 (set spaces (\\\$spaces )))
  34.  
  35. # Puts the n characters from the cursor in $string
  36. # usage: string n
  37. setmacro string 1 (push pos set string () \$arg1 (scanf c set string (\\\$string\\\$scanf) right) pop pos)
  38.  
  39. # Indicates which type a block is.
  40. # Toggle 5 is set if it is a line block.
  41. # Toggle 6 is set if it is a character block.
  42. # Otherwise it is a vertical block.
  43. # Vertical blocks one row in height are classified as character blocks.
  44. setmacro block-type? 0 (goto end right ifelse cb (settoggle 5 left) (resettoggle 5 up ifelse cb (settoggle 6 left down) (left ifelse cb (resettoggle 6) (settoggle 6))))
  45.  
  46. # Stores a string into the nth member of an array
  47. # usage: array <arrayname> <n> <string>
  48. setmacro array 3 (setenv \$arg1\$arg2 (\$arg3))
  49.  
  50. # Inserts the nth member of an array.
  51. # Unfortunately, it doesn't work, which makes "array" useless.
  52. # usage: insarray <arrayname> <n>
  53. setmacro insarray 2 (insert \$$arg1$arg2)
  54.  
  55. #List Processing macros
  56. # These are like LISP commands with some limitations:
  57. # 1) Lists cannot be members of lists
  58. # 2) These commands convert everything to upper case
  59.  
  60. # Stores the car of a list into a variable
  61. # usage: car <list> <var>
  62. setmacro car 2 (rx1 "arg list;c='set \$arg2' word(list,1);c" (\$arg1))
  63.  
  64. # Stores the cdr of a list into a variable
  65. # usage: cdr <list> <var>
  66. setmacro cdr 2 (rx1 "arg list;c='set \$arg2 ('subword(list,2)')';c" (\$arg1))
  67.  
  68. #Menus
  69.  
  70. menuoff
  71. menuclear
  72.  
  73. menusubadd Project About (XDMD V1.00 by Fergus Patrick Duniho) null
  74. menusubadd Project About (Copyright © 1994 Fergus Duniho) null
  75. menusubadd Project About (Fidonet: The FileWorks BBS 1:2613/278) null
  76. menusubadd Project About (Internet: fdnh@troi.cc.rochester.edu) null
  77. menusubbar Project About
  78. menusubadd Project About (XDMD is Freeware, but donations will) null
  79. menusubadd Project About (make me happy. Send anything to me at) null
  80. menusubadd Project About () null
  81. menusubadd Project About (Fergus Duniho) null
  82. menusubadd Project About (1095 Genesee St.) null
  83. menusubadd Project About (Rochester, NY 14611 USA) null
  84. menusubadd Project Load (Replace ... A-o) A-o
  85. menusubadd Project Load (New     ... A-n) A-n
  86. menusubadd Project Load (Insert  ...  F1) f1
  87. menusubadd Project Load (Diary   ...  F2) f2
  88. menusubadd Project Load (Decrypt ...  F3) f3
  89. menusubadd Project Save (Save    ... A-s) A-s
  90. menusubadd Project Save (Save As ...  F9) f9
  91. menusubadd Project Save (Block   ...  F8) f8
  92. menusubadd Project Print (Draft Print) (title (Hit RETURN to Print in Draft Mode, ESC to exit) escimm (writeto T:TEXT execute (Copy S:Draft PRT:) execute (Run <NIL: >NIL: Move T:TEXT PRT:)))
  93. menusubadd Project Print (NLQ Print) (title (Hit RETURN to Print in NLQ Mode, ESC to exit) escimm (writeto T:TEXT execute (Copy S:NLQ PRT:) execute (Run <NIL: >NIL: Move T:TEXT PRT:)))
  94. menusubadd Project Print (Print Preview) (writeto T:Text execute (sys:utilities/most T:Text))
  95. menuadd Project Compile (rx Compile)
  96. menusubadd Project Quit (Close Window c-q) c-q
  97. menusubadd Project Quit (Quit All     A-q) quitall
  98.  
  99. menuadd Format (Font ... a-f4) a-f4
  100. menusubadd Format Style (Plain) ((^[[0m))
  101. menusubadd Format Style (Bold) ((^[[1m))
  102. menusubadd Format Style (Italics) ((^[[3m))
  103. menusubadd Format Style (Underline) ((^[[4m))
  104. menusubadd Format Style (Italicize Word) ((^[[3m) while c<>32 right (^[[0m))
  105. menusubadd Format Foreground (Color 0) ((^[[30m))
  106. menusubadd Format Foreground (Color 1) ((^[[31m))
  107. menusubadd Format Foreground (Color 2) ((^[[32m))
  108. menusubadd Format Foreground (Color 3) ((^[[33m))
  109. menusubadd Format Background (Color 0) ((^[[40m))
  110. menusubadd Format Background (Color 1) ((^[[41m))
  111. menusubadd Format Background (Color 2) ((^[[42m))
  112. menusubadd Format Background (Color 3) ((^[[43m))
  113. menubar Format
  114. menusubadd Format Reformat (Reformat ¶               a-f) a-f
  115. menusubadd Format Reformat (Reformat Entire Document) (top while !b (xa-f first while !r downadd down))
  116. menusubadd Format Reformat (Indent & Reformat Each ¶) (top a-0 while !b (firstnb split tab join reformat first while !r downadd down))
  117. menusubadd Format Paginate Paginate (writeto t:text execute (paginate <t:text >t:text2 \$pparam) top bstart bottom bend bdelete insfile t:text2)
  118. menusubadd Format Paginate (Set Parameters) (title `Set Parameters for "Paginate"' escimm (settvar pparam `))
  119. menusubadd Format Paginate (Show Parameters) (title `\$pparam')
  120. menusubadd Format Justify (Left Justify @ Column 1        A-[) A-[
  121. menusubadd Format Justify (Left Justify @ Cursor          A-@) A-@
  122. menusubadd Format Justify (Right Justify @ Margin         A-]) A-]
  123. menusubadd Format Justify (Center                         A-=) A-=
  124. menusubadd Format Justify (Justify Full                   A-j) A-j
  125. menusubadd Format Justify (Unjustify                      A-J) A-J
  126. menusubadd Format Justify (Indent N Spaces                A-i) A-i
  127. menusubadd Format Justify (Align Line with Previous Line  A-{) A-{
  128. menusubadd Format Justify (Hanging Indent                 c-h) c-h
  129. menusubadd Format Spacing (Single Space  A-1) A-1
  130. menusubadd Format Spacing (Double Space  A-2) A-2
  131. menusubadd Format Margin (Enter Left Margin ... ) (escimm (setparcol ))
  132. menusubadd Format Margin (Enter Right Margin ...) (escimm (margin ))
  133. menusubadd Format Margin (Margin Release     a-0) a-0
  134. menusubadd Format Margin (Set Left Margin    a-[) a-[
  135. menusubadd Format Margin (Set Right Margin   a-]) a-]
  136. menusubadd Format Margin (No Left Margin     a-=) a-=
  137. menusubadd Format Tabs (Set Tabstops) (set x (\$colno) dec x tabstop (\$x))
  138. menusubadd Format Tabs (Enter Tabstops ...) (escimm (tabstop ))
  139. menusubadd Format Outline (Position Roman Heading) Mys-tab
  140. menusubadd Format Outline (Position Non-Roman Heading) My-tab
  141. #menusubadd Format Outline (Increment Heading               A-nk+) A-nk+
  142. #menusubadd Format Outline (Decrement Heading               A-nk-) A-nk-
  143. menusubadd Format Outline (Align Section w/ Above Section) (rx AlignHeading sa-[ ca-o)
  144. menusubadd Format Outline (Subordinate Section) (rx DownLevel sa-[ ca-o)
  145. menusubadd Format Outline (Reformat Entire Outline) (top while !b (My-f first while !l downadd down))
  146. menusubadd Format Outline (Left Shift Outline Block) (goto block while cb (c-, first while !r down down))
  147. menusubadd Format Outline (Right Shift Outline Block) (goto block while cb (c-. first while !r down down))
  148. menusubadd Format Outline (Renumber Outline Block) (rx RenumberOutline title \$RS)
  149.  
  150. menusubadd Edit Blocking (Begin/End A-b) block
  151. menusubadd Edit Blocking (Unblock   A-u) unblock
  152. menusubadd Edit Blocking (Region    a-b) block-region
  153. menusubadd Edit Blocking (All       A-a) $(A-a)
  154. menusubadd Edit Blocking (Paragraph) Mx-p
  155. menusubadd Edit Blocking (Section) Mx-b
  156. menusubadd Edit (All Blocks) (Cut    A-x) A-x
  157. menusubadd Edit (All Blocks) (Copy   A-c) A-c
  158. menusubadd Edit (All Blocks) (Delete A-d) A-d
  159. menusubadd Edit (Line Blocks) (Copy  A-k) bcopy
  160. menusubadd Edit (Line Blocks) (Move  A-m) bmove
  161. menusubadd Edit (Line Blocks) (Sort) (bsave T:TEXT execute (C:Sort T:TEXT to T:TEXT) goto block bdelete insfile T:TEXT rx "Z=Delete('T:TEXT')")
  162. menusubadd Edit (Vertical Blocks) (Open) (mark-block open-rectangle)
  163. menusubadd Edit (Vertical Blocks) (Clear) (mark-block clear-rectangle)
  164. menusubadd Edit Regions (Mark   c-@) sc-2
  165. menusubadd Edit Regions (Kill   c-w) c-w
  166. menusubadd Edit Regions (Copy   a-w) a-w
  167. menusubadd Edit Regions (Yank   c-y) c-y
  168. menusubadd Edit Regions (Delete) delete-region
  169. menusubadd Edit Rectangles (Copy) copy-rectangle
  170. menusubadd Edit Rectangles (Kill) kill-rectangle
  171. menusubadd Edit Rectangles (Delete) delete-rectangle
  172. menusubadd Edit Rectangles (Open) open-rectangle
  173. menusubadd Edit Rectangles (Clear) clear-rectangle
  174. menusubadd Edit Insertion (Paste Clipboard A-v) A-v
  175. menusubadd Edit Insertion (Yank Clipboard  c-y) c-y
  176. menusubadd Edit Insertion (Yank Rectangle) yank-rectangle
  177. menusubadd Edit Insertion (Literal ...     A-l) A-l
  178. menusubadd Edit Insertion (ASCII ...      ac-a) ac-a
  179. menusubadd Edit Insertion (Signature) (insfile S:.signature)
  180. menusubadd Edit Lines (Undo      A-z) undo
  181. menusubadd Edit Lines (Delete  a-nk.) a-nk.
  182. menusubadd Edit Lines (Undelete  a-z) a-z
  183. menusubadd Edit Lines (Insert  a-nk0) a-nk0
  184. menusubadd Edit Case (UPPER CASE  a-u) a-u
  185. menusubadd Edit Case (lower case  a-l) a-l
  186. menusubadd Edit Case (Mixed Case  a-m) a-m
  187.  
  188. menusubadd Seek Find (Find  ... A-f) A-f
  189. menusubadd Seek Find (Next F    a-n) a-n
  190. menusubadd Seek Find (Prev F    a-p) a-p
  191. menusubadd Seek Find (Next @    c-n) c-n
  192. menusubadd Seek Find (Prev @    c-p) c-p
  193. menusubadd Seek Find (Findstr @ c-f) c-f
  194. menusubadd Seek Replace (Replace ... A-r) A-r
  195. menusubadd Seek Replace (Replace F   a-r) a-r
  196. menusubadd Seek Replace (Replace @   A-e) A-e
  197. menusubadd Seek Replace (Next) (nextr)
  198. menusubadd Seek Replace (Prev) (prevr)
  199. menusubadd Seek Replace (Repstr @  c-r) c-r
  200. menusubadd Seek Goto (Line ... A-g) A-g
  201. menusubadd Seek Goto (Block Start) (goto start)
  202. menusubadd Seek Goto (Block End) (goto end)
  203. menusubadd Seek Settings (Case Sensitive Search) (ignorecase off set igncase 0)
  204. menusubadd Seek Settings (Case Insensitive Search) (ignorecase on set igncase 1)
  205. menusubadd Seek Settings (Global Search) (global on)
  206. menusubadd Seek Settings (Local Search) (global off)
  207.  
  208. menusubadd Settings Blocktype (Line) (blocktype line)
  209. menusubadd Settings Blocktype (Character) (blocktype character)
  210. menusubadd Settings Blocktype (Vertical) (blocktype vertical)
  211. menusubadd Settings (Minor Modes) (Insert Mode) (insertmode toggle)
  212. menusubadd Settings (Minor Modes) (Wordwrap) (wordwrap toggle)
  213. menusubadd Settings (Minor Modes) (Autosplit) (autosplit toggle)
  214. menusubadd Settings (Minor Modes) (Autoindent) (autoindent toggle)
  215. menusubadd Settings (Minor Modes) (Savetabs) (savetabs toggle)
  216. menusubadd Settings (Minor Modes) (Smart Cursor Keys) (toggle 102 ifelse 102 (title `Smart Cursor Keys Mode') (title `Dumb Cursor Keys Mode'))
  217. menusubadd Settings (Minor Modes) (Viewmode) (viewmode toggle)
  218. menusubadd Settings (Major Modes) (Programming) c-f1
  219. menusubadd Settings (Major Modes) (ANSI C / C++) c-mode
  220. menusubadd Settings (Major Modes) (K&R C) krc-mode
  221. menusubadd Settings (Major Modes) (Text) text-mode
  222. menusubadd Settings (Major Modes) (Outline) outline-mode
  223. menusubadd Settings (Major Modes) (Proofs) proofs-mode
  224.  
  225. menusubadd Misc XPK (Select Method) (rx "Z='settvar method' substr(GetFile(,,'LIBS:compressors',,'Select XPK Method'),21,4); Z")
  226. menusubadd Misc XPK (Select Password) (reqstring (XPK Password Requester) (Please Enter Password) OK|Cancel () settvar password (\$reqresult))
  227. menusubadd Misc Spelling (Check Spelling    ...) (writeto T:TEXT rx AlphaSpell)
  228. menusubadd Misc Spelling (Select Dictionary ...) (reqfile (Select Dictionary) () \$Dict set Dict \$reqresult)
  229. menusubadd Misc Spelling (Peruse Dictionary) (execute (SYS:Utilities/more \$Dict))
  230. menusubadd Misc Source (File) (reqfile (Source File ...) () (S:.edrc) source \$reqresult)
  231. menusubadd Misc Source (Block  c-s) c-s
  232. menusubadd Misc Convert (NL -> NL/CR) (writeto t:text execute (addcr <t:text >t:text2) top block bottom block bdelete insfile t:text2)
  233. menusubadd Misc Convert (NL/CR -> NL) (writeto t:text execute (remcr <t:text >t:text2) top block bottom block bdelete insfile t:text2)
  234. menusubadd Misc Convert (// -> /* */) (autosplit off top repeat -1 (findr // /* last ` */'))
  235. menusubadd Misc Info (General) (title ("\$filename" \$mode Mode xpk\$(method).library))
  236. menusubadd Misc Info (Display Time  c-2) c-2
  237. menusubadd Misc Info (Count Words  a-F3) a-f3
  238.  
  239. menuadd Disk (Delete Files     ...) (rx1 MultiFiles Delete)
  240. menuadd Disk (Copy Files       ...) (rx1 MultiFiles Copy)
  241. menuadd Disk (Move Files       ...) (rx1 MultiFiles Move)
  242. menuadd Disk (Print Files      ...) (rx1 MultiFiles Print)
  243. menuadd Disk (Rake Files       ...) (rx1 MultiFiles Rake)
  244. menuadd Disk (Unpack Files     ...) (rx1 MultiFiles Unpack)
  245. menuadd Disk (Extract Archives ...) (rx1 MultiFiles Unarchive)
  246. menuadd Disk (View Archives    ...) (rx1 MultiFiles ViewArc)
  247. menuadd Disk (Run Programs     ...) (rx1 MultiFiles Run)
  248. menuadd Disk (Call ARexx Macro ...) (rx "GetFile(,,'Rexx:',,'Call ARexx Macro',,'PATGAD',,,,'#?.rexx')")
  249. #menuadd Disk (Call ARexx Macro ...) (pattern #?.rexx reqfile (Call ARexx Macro) () (REXX:) rx \$reqresult)
  250.  
  251. menuon
  252. savetabs on
  253. autounblock on
  254.  
  255. #map A-p `push savetabs push modified savetabs off writeto prt: pop auto pop auto'
  256.  
  257. #Cursor Keys
  258.  
  259. setmacro goleft 0 (ifelse l (up last) left)
  260. setmacro goright 0 (ifelse r (down firstnb) right)
  261.  
  262. map down (down if 102 (if r last))
  263. map left goleft
  264. map right goright
  265. map up (up if 102 (if r last))
  266.  
  267. map a-up (sc-2 first top)
  268. map a-down (sc-2 bottom last)
  269. map a-left  (firstnb)
  270. map a-right (last)
  271.  
  272. map c-up scrollup
  273. map c-down scrolldown
  274. map c-left scrollleft
  275. map c-right scrollright
  276.  
  277. map s-up (pageup)
  278. map s-down (pagedown)
  279. map s-left (wleft)
  280. map s-right (wright)
  281.  
  282. #Major Modes
  283.  
  284. setmacro prog-mode 0 (unsettvar mode unsettvar cr unsettvar ftab unsettvar btab unsettvar rbrace autosplit off wordwrap off setparcol -1 tabstop 4 blocktype line)
  285. map c-f1 prog-mode
  286. setmacro c-mode 0 (c-f1 settvar mode (ANSI C) settvar ftab C_tab settvar rbrace C_brace map Mc-t Mc-a)
  287. setmacro krc-mode 0 (c-f1 settvar mode (K&R C) settvar ftab C_tab settvar rbrace C_brace map Mc-t Mc-k)
  288. setmacro outline-mode 0 (c-f1 settvar mode (Outline) settvar cr My-return settvar ftab My-tab settvar btab Mys-tab wordwrap on)
  289. setmacro text-mode 0 (c-f1 settvar mode (Text) settvar cr text_return wordwrap on setparcol 0 blocktype character)
  290. setmacro proofs-mode 0 (c-f1 settvar mode (Proofs) settvar cr M-return settvar ftab M-tab setfont clean 8)
  291.  
  292. #Mode Specific Keys
  293.  
  294. map return (\$cr)
  295. map tab (\$ftab)
  296. map s-tab (\$btab)
  297. map s-] (\$rbrace)
  298.  
  299. map sx-] ((}))
  300.  
  301. #Tabs
  302.  
  303. map a-tab (ifelse cb (indent b .t) (indent . .t) firstnb)
  304. map sa-tab (ifelse cb (indent b -.t) (indent . -.t) firstnb)
  305.  
  306. map c-tab (repeat tr (( )))
  307. map sc-tab (repeat tl bs)
  308.  
  309. #Margins
  310.  
  311. map a-0 (setparcol 0 title `Left Margin Set To 0')
  312. # a-[ sets the left margin to the column position.
  313. map a-[ (ifelse l a-0 sa-[)
  314. # a-] sets the right margin to the column position.
  315. map a-] (margin (\$colno) title `Right Margin Set To (\$colno)')
  316. map a-= (setparcol -1 title `Left Margin Set To -1')
  317.  
  318. #Justification
  319.  
  320. map A-[ (ifelse cb (goto end while cb (justify left up) goto start) (justify left))
  321. map A-] (ifelse cb (goto end while cb (justify right up) goto start) (justify right))
  322. map A-= (ifelse cb (goto end while cb (justify center up) goto start) (justify center))
  323. map A-@ (if !cb lineblock set m (\$colno) dec m indent b -255 indent b (\$m) unblock)
  324. map A-j (ifelse cb (goto end first while cb (justify full up if r (up up))) (justify full))
  325. map A-J (ifelse cb (goto end while cb (unjustify up) goto start) unjustify)
  326. map A-i (title (Enter the number of spaces to indent.) escimm (set m ) indent b (\$m) unblock)
  327. map A-{ (up firstnb set m (\$colno) dec m down indent . -255 indent . (\$m))
  328.  
  329. #Format
  330.  
  331. map c-h (indent . -255 first set m 9 while ca right sub m (\$colno) indent . (\$m) My-f)
  332. map xa-f (down firstnb ifelse r (a-= up) (a-[ up join) reformat)
  333. map x-p (title `Enter First Page #' escimm (set pn ) top while !b (inslines 6 repeat 31 downadd inslines 3 goto +3 insert (\$pn) A-= inc pn last tlate 12 downadd))
  334.  
  335. #Outline
  336.  
  337. map My-tab (indent . -255 first ifelse cn (set m 17) (ifelse cl (set m 25) (set m 13)) My-o)
  338. map Mys-tab (indent . -255 first ifelse cl (set m 21) (set m 9) My-o)
  339. map My-o (while ca right sub m (\$colno) if c=41 (add m 12) indent . (\$m) My-f)
  340. map My-f (firstnb while ca right right ifelse r (tab a-[) My-h)
  341. map My-h (wright split last tab set m (\$colno) dec m down first push block bstart while !r downadd up bend indent b -255 indent b (\$m) goto start unblock pop block firstnb a-[ reformat indent . -255 up join)
  342. map My-return (if !t (first while !r up down) firstnb sc-c first while !r downadd downadd if !r (insline insline) col \$C)
  343.  
  344. #Spacing
  345.  
  346. map x-1 (goto start first while cb (if r deline if !r downadd))
  347. map x-2 (x-1 goto start while cb (down if cb (insline down)))
  348. map A-1 (ifelse cb x-1 (Mx-p x-1 unblock pop block))
  349. map A-2 (ifelse cb x-2 (Mx-b x-2 unblock pop block))
  350. map xy-2 (goto start while cb (Mx-b x-2 down pop block))
  351. map xy-2 (top while !b (Mx-b x-2 down))
  352. map xy-1 (top while !b (Mx-p x-1 down))
  353. map A-! (x-1 goto start while cb (if !t (firstnb if !l (insline down)) downadd))
  354.  
  355. #Proofs
  356.  
  357. map M-tab (col 40 if !r (last col +5) insert (// ))
  358. map M-return (firstnb scanf %[0123456789] set ln (\$scanf) last split down first inc ln insert (\$ln.) up first wright if c="Show" (col +2) down)
  359. map a-| (goto block first find Show down while cb (overwrite (|) left down) unblock)
  360.  
  361. map `a-(' ``¬''
  362. map `a-)' ``º''
  363. map a-nk/ ``÷''
  364. map a-nk* ``ª''
  365.  
  366. #Deletion
  367.  
  368. map bs (ifelse l (up last join if !l right) (ifelse i bs (left ` ' left)))
  369. map del (ifelse r (if !b (last join)) del)
  370.  
  371. map a-bs (ifelse l (up last join right) (split scanf l deline first))
  372. map a-del (ifelse r join (scanf l remeol))
  373.  
  374. map s-del (if c=32 wright scanf w findstr (\$scanf) repstr `' replace right bs)
  375. map s-bs (resettoggle 1 if !l (left if c<>32 (toggle 1) right) if 1 (( )) wleft scanf %s findstr (\$scanf) repstr `' replace right if !l (while c=32 del))
  376.  
  377. #Insertion
  378.  
  379. map s-nk0 (insert (\$scanf ))
  380. map (a- ) (firstnb insline)
  381. map (A- ) (firstnb inslines 3 down)
  382. map A-l (InsLit)
  383.  
  384. #Case
  385.  
  386. map xa-u (if cl (tlate -32))
  387. map a-u (ifelse cb (goto block firstnb while cb (xa-u goright)) (while c<>32 (xa-u right) wright))
  388. map xa-l (if cu (tlate +32))
  389. map a-l (ifelse cb (goto block firstnb while cb (xa-l goright)) (while c<>32 (xa-l right) wright))
  390. map xa-m (xa-u goright while c<>32 (xa-l goright) wright)
  391. map a-m (ifelse cb (goto block firstnb while cb xa-m) xa-m)
  392.  
  393. #Block
  394.  
  395. map A-a (bottom last block top first block)
  396. map A-k (blocktype line bcopy)
  397. map A-m (blocktype line bmove)
  398. map A-u (unblock)
  399. map c-s (ifelse cb (blocktype line) lineblock bsource)
  400. map Mx-b (push block first while !r (if t break up) if r down bstart while !r (down if b break) if r up bend)
  401. map Mx-p (push block firstnb while l (up if t break firstnb) bstart down firstnb while l (down if b break firstnb) if !l up last while l (up last) bend)
  402.  
  403. #Line
  404.  
  405. map a-nk. (first deline)
  406. map a-nk0 (split down undeline up join join)
  407. map a-nk2 (deline downadd undeline)
  408. map a-nk4 (wleft a-t)
  409. map a-nk6 (a-t wright)
  410. map a-nk8 (deline up undeline)
  411. map a-z (undeline)
  412.  
  413. #File Requester
  414.  
  415. map f1 (arpinsfile)
  416. map f2 (rx Diary text-mode)
  417. map f3 (rx1 FileOp Decrypt)
  418. map f8 (barpsave)
  419. map f9 (rx1 FileOp Saveas)
  420. map A-o (rx1 FileOp Replace)
  421. map A-n (rx1 MultiFiles Load)
  422.  
  423. #Other File Operations
  424.  
  425. map c-f4 (ca-w title `Change Filename' escimm (chfilename `\$filename) sc-w)
  426. map c-q (rx Quit)
  427. map A-s (rx Save)
  428.  
  429. #Miscellaneous Requesters
  430.  
  431. map a-f4 (FontReq)
  432. map ac-a (rx "C='insert' d2c(rtgetlong(,'Enter ASCII value.','Insert ASCII Requester',,'rtgl_min=0 rtgl_max=255')); C")
  433. map A-g (rx "C='force r (goto' rtgetlong(,'Enter Line # ...','Goto Line Requester',,'rtgl_min=1')')'; C")
  434. #map A-g (push pos bottom sc-l pop pos reqnumber (Goto Line Requester) (Enter Line # ...) OK|Cancel () 1 \$L goto \$reqresult)
  435.  
  436. #Find & Replace
  437.  
  438. map a-a (ignorecase on)
  439. map a-A (ignorecase off)
  440. map A-f (rx ReqFind)
  441. map A-e (scanf b setenv F (\$scanf) findstr (\$F) repstr (\$R) replace wright)
  442. map A-r (rx RepReq)
  443. map a-r (if c="\$F" replace)
  444.  
  445. map a-n (find (\$F))
  446. map a-p (findstr (\$F) prev)
  447. map c-n (scanf %s setenv F (\$scanf) find (\$F))
  448. map c-p (scanf %s setenv F (\$scanf) findstr (\$F) prev)
  449. map c-r (scanf %s setenv R (\$scanf) repstr (\$R))
  450. map c-f (scanf %s setenv F (\$scanf) findstr (\$F))
  451.  
  452. #Ping Pong
  453.  
  454. map s-f1 (ping 1)
  455. map s-f2 (ping 2)
  456. map s-f3 (ping 3)
  457. map s-f4 (ping 4)
  458. map s-f5 (ping 5)
  459. map s-f6 (ping 6)
  460. map s-f7 (ping 7)
  461. map A-f1 (pong 1)
  462. map A-f2 (pong 2)
  463. map A-f3 (pong 3)
  464. map A-f4 (pong 4)
  465. map A-f5 (pong 5)
  466. map A-f6 (pong 6)
  467. map A-f7 (pong 7)
  468.  
  469. #Minor Modes
  470.  
  471. map A-w (wordwrap toggle)
  472.  
  473. #C Mode
  474.  
  475. setmacro C_tab 0 (ifelse cb (goto block while cb (Mc-t down) goto block) Mc-t)
  476. setmacro C_brace 0 ((}) ping 9 firstnb ifelse c="}" Mc-1 (pong 9))
  477.  
  478. map Mc-a (indent . -255 first ifelse c="{" (up join) (Mc-g Mcs-2))
  479. map Mc-k (indent . -255 first ifelse c="{" (up firstnb set m (\$colno)) Mc-g Mcs-2)
  480.  
  481. map Mc-g (set m 1 if c<>"#" (ifelse c="else" Mc-e (ifelse c="}" Mc-2 (Mc-f if 5 (ping 9 wleft ifelse c="else" Mcs-0 (last left ifelse c=41 Mcs-0 (ifelse c="," Mc-, Mc-;)))))))
  482.  
  483. map Mcs-0 (firstnb tab set m (\$colno) pong 9)
  484. map Mc-; (pong 9 insert (}) left force s match sc-l if c="{" (force s firstnb if c="switch" (force s tab) set m (\\\$colno) pong 9) del add m 4 last if !l (left if c=":" (sub m 4)) pong 9)
  485. map Mc-, (pong 9 insert (}) left force s match sc-l if c="{" (force s firstnb if c="switch" (force s tab) tab set m (\\\$colno) pong 9) del add m 4 last if !l (left if c=":" (sub m 4)) pong 9)
  486.  
  487. map Mc-f (settoggle 5 if !r (insert (}) left force s match ifelse c="{" (force s match) (resettoggle 5) del))
  488. #map Mcs-2 (ifelse r (col (\$m)) (split col (\$m) join))
  489. map Mcs-2 (ifelse r (col (\$m)) (indent . (\$m) indent . -1))
  490. map Mc-1 (ping 9 force s match force s firstnb sc-c pong 9 del col (\$C) (}))
  491. map Mc-2 (ping 9 force s match force s firstnb set m (\$colno) pong 9)
  492.  
  493. map Mc-L (resettoggle 5 up firstnb if c<>"}" (if (c<>"else if") (if c<>"if" (ifelse c="else" backtab (settoggle 5)))))
  494. map Mc-e (ping 9 settoggle 5 while 5 Mc-L set m (\$colno) pong 9)
  495.  
  496. #Text Mode
  497.  
  498. setmacro text_return 0 (if !l (split down) insline down indent . .t first tab tab reformat)
  499. setmacro text_tab 0 (ifelse cb (indent b -255 indent b t goto start firstnb a-[ reformat) (indent . .t firstnb))
  500. setmacro text_backtab 0 (indent . -.t firstnb)
  501.  
  502. #Miscellaneous
  503.  
  504. map c-2 (rx "C='('Date('W') Date() Time()')'; 'title' C")
  505. map help (newwindow newfile S:.edrc c-f1 sc-w settvar method RAKE)
  506. map s-help (newwindow newfile S:startup-sequence c-f1 sc-w)
  507. map a-; (first while !r (firstnb split first join ( ::> ) downadd))
  508. map a-/ (first while !r (firstnb split first join ( // ) downadd))
  509. map a-. (first while !r (firstnb split first join ( **> ) downadd))
  510. map as-8 (insline first insert (/*) down while !r (firstnb split first join ( * ) reformat downadd) insline first insert ( */))
  511.  
  512. map a-f3 (writeto `T:TEXT' execute (wcnt <T:TEXT >ENV:titlebar) rx "z=delete('T:TEXT')" title (\$titlebar))
  513. map A-q quitall
  514.  
  515. #EMACS Keymappings
  516.  
  517. #map c-x (title `C-X ...' qualifier x)
  518. map cx-s A-s
  519. map cx-k c-q
  520. map cx-c QuitAll
  521. map cx-w f9
  522. map c-t (scanf c set c0 (\$scanf) goleft scanf c overwrite (\$c0) ifelse r (if !b (down first del)) (overwrite (\$scanf)))
  523. map c-l (sc-l ifelse c>24 top bottom goto \$L)
  524. map c-e last
  525. map c-a first
  526. map c-k a-del
  527. map xs-9 (recstart)
  528. map xs-0 (recend)
  529. map x-e (recplay)
  530.  
  531. #Region (Keymappings match Emacs where applicable)
  532.  
  533. # Stores coordinates of point into $arg1 and $arg2
  534. setmacro mark-point 2 (settvar \$arg1 \$colno settvar \$arg2 \$lineno)
  535.  
  536. # Set Mark
  537. # $mx and $my are the column and row of the mark respectively.
  538. # They are local variables, so that each window has its own mark.
  539. map sc-2 (mark-point mx my title (Mark Set))
  540. map (c- ) sc-2
  541.  
  542. # Goto Mark
  543. setmacro goto-mark 0 (goto (\$my) col (\$mx))
  544.  
  545. # Swap Mark and Point
  546. map cx-x (mark-point tx ty goto-mark settvar mx \$tx settvar my \$ty)
  547. map c-x cx-x
  548.  
  549. # Block Region
  550. # Marks the the region as a block.
  551. setmacro block-region 0 (region-top bstart cx-x goleft bend goright)
  552. map a-b block-region
  553.  
  554. # Mark Block as Region
  555. # The point marks the top of the range.
  556. setmacro mark-block 0 (goto end right ifelse cb (first downadd sc-2 goto start first) (sc-2 goto start))
  557.  
  558. # Indicates whether Mark precedes Point
  559. # toggle 7 = 1 if Mark precedes Point
  560. # toggle 7 = 0 if Mark doesn't precede Point
  561. setmacro mark-first? 0 (resettoggle 7 ifelse y>\$my (settoggle 7) (if y=\$my (if x>\$mx (settoggle 7))))
  562.  
  563. # Goto Top of Region
  564. setmacro region-top 0 (mark-first? if 7 cx-x)
  565.  
  566. # Goto End of Region
  567. setmacro region-end 0 (mark-first? if !7 cx-x)
  568.  
  569. # Calulates distances between Mark and Point
  570. # $dy = abs((Mark row) - (Point row))
  571. # $dx = abs((Mark column) - (Point column))
  572. setmacro x-distance 0 (minus dx \$colno \$mx if x<\$mx (neg dx))
  573. setmacro y-distance 0 (minus dy \$lineno \$my if y<\$my (neg dy))
  574. map xy-d (x-distance y-distance)
  575.  
  576. # Delete Region
  577. setmacro delete-region 0 (region-top xy-d ifelse y=\$my (\$dx del) (cx-x split cx-x remeol down \$dy deline up last ifelse l deline join))
  578.  
  579. # Copy Region to Clipboard
  580. map a-w (blocktype character block-region cx-x copy unblock)
  581.  
  582. # Kill Region and Copy to Clipboard
  583. map c-w (blocktype character block-region copy delete-region unblock sc-2)
  584.  
  585. # Yank from Clipboard and Mark yanked text as Region.
  586. # This also compensates for a bug (or feature) in "copy,"
  587. # which A-v doesn't compensate for: "Copy" inserts a
  588. # linefeed after the text it inserts into the clipboard.
  589. map c-y (sc-2 clipins -bs)
  590.  
  591. #Block Editing
  592.  
  593. # Copy Block
  594. # Copies line and character blocks to the clipboard.
  595. # Copies vertical blocks to T:rectangle.
  596. map A-c (ifelse cb (block-type? ifelse 5 copy (ifelse 6 copy (mark-block copy-rectangle))) (lineblock copy) unblock)
  597.  
  598. # Cut Block
  599. # Cuts line and character blocks to the clipboard
  600. # Cuts vertical blocks to T:rectangle
  601. map A-x (ifelse cb (block-type? ifelse 5 (copy bdelete) (ifelse 6 (copy mark-block delete-region) (mark-block kill-rectangle))) (lineblock copy bdelete))
  602.  
  603. # Delete Block
  604. # Deletes any sort of block
  605. # If the cursor is not in a block, it deletes the current line
  606. map A-d (ifelse cb (block-type? ifelse 5 bdelete (ifelse 6 (mark-block delete-region) (mark-block delete-rectangle))) deline)
  607.  
  608. # Paste contents of Clipboard
  609. map A-v clipins
  610.  
  611. #Rectangles
  612. # Commands which operate on region-rectangles, ala Emacs
  613.  
  614. # Goto top left of region-rectangle, set mark at bottom right
  615. setmacro topleft-rectangle 0 (mark-point tx ty if x>\$mx (col \$mx settvar mx \$tx) if y>\$my (goto \$my settvar my \$ty))
  616.  
  617. # Marks region-rectangle as a vertical block
  618. setmacro block-rectangle 0 (topleft-rectangle blocktype vertical bstart cx-x left bend right)
  619.  
  620. # Calculates dimensions of Rectangle
  621. # Also creates a blank line equal to its width
  622. setmacro dimrec 0 (topleft-rectangle xy-d inc dy spaces \$dx)
  623.  
  624. # Deletes rectangle
  625. setmacro delete-rectangle 0 (dimrec push pos findstr \$spaces repstr () \$dy (replace down) pop pos)
  626.  
  627. # Pushes the contents of a rectangle to its right
  628. setmacro open-rectangle 0 (dimrec push pos \$dy (push pos insert (\$spaces) pop pos down) pop pos)
  629.  
  630. # Fills rectangle with spaces
  631. setmacro clear-rectangle 0 (dimrec push pos \$dy (push pos overwrite (\$spaces) pop pos down) pop pos)
  632.  
  633. # Copies rectangle to T:rectangle
  634. setmacro copy-rectangle 0 (block-rectangle cx-x rx2 copyrec \$colno \$mx unblock)
  635.  
  636. # Kills rectangle
  637. setmacro kill-rectangle 0 (copy-rectangle delete-rectangle)
  638.  
  639. # Yanks killed rectangle and marks it as a region-rectangle
  640. setmacro yank-rectangle 0 (push pos rx yankrec sc-2 pop pos)
  641.  
  642. # Replaces every occurance of F with R within a region-rectangle
  643. setmacro replace-rectangle 0 (block-rectangle findstr (\$F) repstr (\$R) while y>=\$my (prev if cb replace) goto end sc-2 goto start)
  644.  
  645. #Mouse stuff
  646.  
  647. map L-lmb (tomouse)
  648. map L-mmove (tomouse)
  649. map sL-lmb (tomouse bstart)
  650. map sL-mmove (tomouse bend)
  651. map L-lm2 (tomouse if cb unblock)
  652.  
  653. #Internal Hidden Functions
  654.  
  655. map sc-c (set C (\$colno))
  656. map sc-l (set L (\$lineno))
  657. map ca-w (menudel Window (\$fname))
  658. map sc-w (menuadd Window (\$fname) (select (window=\$fname)))
  659.  
  660. # Toggles two words.
  661. map a-t (scanf +b repstr (\$scanf) wright scanf +b findstr (\$scanf) replace repstr (\$scanf) scanf +b findstr (\$scanf) prevr)
  662.  
  663. map sa-[ (left ifelse x<\$margin (setparcol \$colno title `Left Margin Set To \$colno') (title (Can't Set Left Margin To \$colno. The Right Margin is \$margin.)) right)
  664. map ca-o (if !r (ping 0 firstnb wright split return while !r (firstnb split first join return) pong 0 down while !r (insline join down) pong 0 down reformat firstnb split first join pong 0 join))
  665.  
  666. #Settings
  667.  
  668. bgpen 0
  669. fgpen 2
  670. tbpen 3
  671. tfpen 1
  672. hgpen 7
  673. ignorecase on
  674. autoindent on
  675. autounblock on
  676. insertmode on
  677. savetabs off
  678. pageset 99
  679. nicepaging on
  680. blockendsfloat off
  681. setdeftitle (X:%c Y:%l %L %m %b %C %p %f %i)
  682. c-f1
  683. settoggle 102
  684. sc-w
  685.